#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include "variables.hpp"
#include "typedefs.hpp"

#include <vector>
#include <string>
#include <map>
using namespace std;

#include "os.hpp"
#ifndef BIT
#define BIT(m_n) (1<<(m_n-1))
#endif

inline void ShowArgs(vector<Variable> argv)
{
	for(unsigned i=0;i<argv.size();i++) {
		argv[i].tell();
	}
}

class Environment;

typedef Variable(*Function)(vector<Variable>&, Environment&);

typedef enum EnvFlag{
	No_Env_Flags = 0,
	Break_Scope = BIT(1)
} EnvFlag;

class Environment {
public:
	map <string, vector<Variable> > _alias;
	vector< map<string, Variable> > _var;
	map<string, Function> _func;
	vector<string> _paths;
	map<string, vector<Variable> > repl;
	map<string, Typedef> types;
	unsigned long flags;
private:
	unsigned scope;
public:
	Environment(void);
	Environment* add(string, Function);
	void inscope(void);
	void outscope(void);
	unsigned getScope(void) { return scope; }
	Variable& getvar(string);
	Variable& verify(Variable&);
};

string findfile(Environment& env, string filename);
bool isAbsolutePath(string str);

#endif
